package com.herui.ota.controller;

import com.herui.ota.config.ControllerNames;
import com.herui.ota.pojo.form.NoneFilterForm;
import com.mlnx.common.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.base.layer.user.entity.Menu;
import org.shan.base.layer.user.service.MenuService;
import org.shan.spring.base.CurdBaseController;
import org.shan.spring.base.annotations.SysLog;
import org.shan.spring.mybatis.service.ICurdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = ControllerNames.MenuName + "接口", tags = {ControllerNames.MenuName + "接口"})
@SysLog(title = ControllerNames.MenuName)
@RestController
@RequestMapping("/menu")
public class MenuController extends CurdBaseController<Menu, Menu, Menu, NoneFilterForm> {
    @Autowired
    private MenuService service;

    @Override
    public ICurdService getService() {
        return service;
    }

    @Override
    public Menu newInstance(Integer id) {
        Menu o = new Menu();
        o.setId(id);
        return o;
    }

    @ApiOperation("获取菜单树")
    @GetMapping("/getTree")
    public Response getTree() {
        return result(service.getTreeCacheMenuVos());
    }
}